]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Search: Don't use IconGrid width for maxDisplayedResults
authorCarlos Soriano <carlos.soriano89@gmail.com>
Tue, 15 Jul 2014 15:09:41 +0000 (17:09 +0200)
committerCarlos Soriano <carlos.soriano89@gmail.com>
Sat, 19 Jul 2014 16:12:43 +0000 (18:12 +0200)
Currently to know how many results we could show for GridResults
we use the width of the bin containing those results. Since it's
expanding it shouldn't be a problem. But it becomes a problem when
no results are displayed, thus the container becomes hidden and
it losts its allocation.
In the next introduction of terms in search we call again
maxDisplayedResults but it doesn't have allocation yet, and therefore no
results are displayed (currently a bug on IconGrid makes the min size =
one icon, so actually we show one and only one icon in this case).

To solve that use the parent container which contains the search results
of all providers or the text label with not displayed results, so it
always have the real available width to calculate maxDisplayedResults.

Thanks Alban Browaeys for the debugging footwork.

https://bugzilla.gnome.org/show_bug.cgi?id=732416

js/ui/search.js

index 9a58e79817205b0ea3ca1e5698bd3cfa4bfc7076..dc2729a4a1bbf005d449625fd13643b604ef6600 100644 (file)
@@ -465,8 +465,14 @@ const GridSearchResults = new Lang.Class({
     Name: 'GridSearchResults',
     Extends: SearchResultsBase,
 
-    _init: function(provider) {
+    _init: function(provider, parentContainer) {
         this.parent(provider);
+        // We need to use the parent container to know how much results we can show.
+        // None of the actors in this class can be used for that, since the main actor
+        // goes hidden when no results are displayed, and then it lost its allocation.
+        // Then on the next use of _getMaxDisplayedResults allocation is 0, en therefore
+        // it doesn't show any result although we have some.
+        this._parentContainer = parentContainer;
 
         this._grid = new IconGrid.IconGrid({ rowLimit: MAX_GRID_SEARCH_RESULTS_ROWS,
                                              xAlign: St.Align.START });
@@ -477,7 +483,9 @@ const GridSearchResults = new Lang.Class({
     },
 
     _getMaxDisplayedResults: function() {
-        return this._grid.columnsForWidth(this._bin.width) * this._grid.getRowLimit();
+        let parentThemeNode = this._parentContainer.get_theme_node();
+        let availableWidth = parentThemeNode.adjust_for_width(this._parentContainer.width);
+        return this._grid.columnsForWidth(availableWidth) * this._grid.getRowLimit();
     },
 
     _renderResults: function(metas) {
@@ -577,7 +585,7 @@ const SearchResults = new Lang.Class({
         if (provider.appInfo)
             providerDisplay = new ListSearchResults(provider);
         else
-            providerDisplay = new GridSearchResults(provider);
+            providerDisplay = new GridSearchResults(provider, this._content);
 
         providerDisplay.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
         this._content.add(providerDisplay.actor);